package hello;

/**
 * Created with IntelliJIDEA.
 * Description:
 * User: ASUS
 * Date: 2025/9/11
 * Time: 22:26
 */
public class SubstringDemo {
    public static void main(String[] args) {
        String text = "Hello, Java World!";

        // 1. 从指定索引截取到末尾
        // 截取从索引 7 开始的所有字符
        String sub1 = text.substring(7);
        System.out.println("从索引7截取: '" + sub1 + "'");

        // 2. 截取指定范围的子串
        // 截取从索引 7 到 11 (不包括11) 的字符
        String sub2 = text.substring(7, 11);
        System.out.println("从索引7到11截取: '" + sub2 + "'");
    }
}
